<div class="box">
    <div class="heading">
        <h1><img alt="" src="<?php echo base_url('assets/admin/images/review.png'); ?>"> All Event</h1>
		<div class="buttons">
            <ul id="add_entry_btn">
                
                
                <li>
                    <a class="button delete" href="#"><span>Delete</span></a>
                </li>
            </ul>
        </div>  
    </div>
    <div class="content">
		<?php echo form_open(); ?>
        <div class="filter">
            <div class="left">
                <div><label>Search By Member Name:</label></div> 
                <input type="text" name="filter[search]" value="<?php echo set_filter('alan_event', 'search'); ?>" /></td>
            </div>
            <div class="left">
                <div><label>Status:</label></div> 
                <?php echo form_dropdown('filter[approve]', array(''=>'', '1'=>'Approved', '0'=>'Unapproved'), set_filter('alan_event', 'approve')); ?></td>
            </div>
            <div class="left filter_buttons">
                <button name="submit" class="button" type="submit"><span>Filter</span></button>
                <button name="clear_filter" value="1" class="button" type="submit"><span>Clear</span></button>
            </div>
            <div class="clear"></div>
        </div>
        <?php echo form_close(); ?>

		<?php echo form_open(null, 'id="form"'); ?>
        <table id="entries_table" class="list">
            <thead>
                <tr>
                    <th width="1" class="center"><input type="checkbox" onClick="$('input[name*=\'selected\']').attr('checked', this.checked);" /></th>
                    <th>Event Photo</th>
                    <th>Event Name</th>
					<th>Event Details</th>
					<th>Event Location</th>
					<th>Event Date</th>
					<th>Event Time</th>
					<th>Event Proprietor</th>
                    <th>Status</th>
					
                    <th class="right">Action</th>
                </tr>
            </thead>
            <tbody>
                <?php if ($alanevent){?>
                    <?php foreach($alanevent as $event){ ?>
                    <tr>
                        <td class="center"><input type="checkbox" value="<?php echo $event['id'] ?>" name="selected[]"/></td>
						<td><img src="<?php echo base_url(); ?>assets/uploads/.thumbs/event/<?php echo $event['event_picture'] == '' ? 'default.png' : $event['event_picture'] ; ?>" alt="" width="60" height="60" /></td>
                        <td><?php echo $event['event_name']; ?></td>
						<td><?php echo $event['event_details']; ?></td>
						<td><?php echo $event['event_location']; ?></td>
                        <td><?php echo $event['event_date']; ?></td>
                        <td><?php echo $event['event_time']; ?></td>
						<td><?php echo $event['firstname'].' '.$event['lastname']; ?></td>
                       
						<td>
							<input type="hidden" value="<?php echo $event['id'] ?>"/>
							<?php echo form_dropdown('approve['.$event['id'].']', array('1'=>'Approved', '0'=>'Unapproved'),set_value('approve',$event['approve']) )?>
						</td>
                        
						<td class="right">[ <?php echo anchor(ADMIN_PATH . "/alan/deleteevent/". $event['id'], 'Delete', 'onclick="return confirm(\'Delete cannot be undone! Are you sure you want to do this?\')"'); ?> ]</td>
                    </tr>
                    <?php } ?>
				<?php }else { ?>
                    <tr class="center"><td colspan="11">No results found.</td></tr>
                <?php } ?>
				
            </tbody>
        </table>
		<div id="paging">
				<?php if($pagination): ?>
					
					<div class="pagination">
						<div class="links"><?php echo $pagination; ?></div>
					</div>
				<?php endif; ?>
			</div>
        <?php echo form_close(); ?>
        
    </div>
</div>
<script>
$(function(){
	$('select').bind('change', function() {
		var id=$(this).prev().val();
		
		$.ajax({
			url: '<?php echo base_url('ajax/aproveevent')?>',
			
			type :'POST',
			data:{eventid:id,approve:this.value},
			beforeSend: function() {
				$('select[name=\'approve\']').after('<span class="wait">&nbsp;<img src="catalog/view/theme/default/image/loading.gif" alt="" /></span>');
			},		
			complete: function() {
				$('.wait').remove();
			},			
			success: function(data) {
				if(data==0)
				{
					alert("Unapproved");
				}
				else{
					alert("Approved");
				}
			}
		});
	});
});
 // Delete
        $('.delete').click( function() {
            if (confirm('Delete cannot be undone! Are you sure you want to do this?'))
            {
                $('#form').attr('action', '<?php echo site_url(ADMIN_PATH . '/alan/deleteevent'); ?>').submit()
            }
            else
            {
                return false;
            }
        });
</script>
